package com.gosophia.dataDictionary.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseAjaxAction;
import com.gosophia.commons.web.logAnnotation.LogRecord;
import com.gosophia.dataDictionary.dto.DataValueDTO;
import com.gosophia.dataDictionary.ws.DataDictionaryWebService;





/**
 * 添加数据值
 * 
 * @author tianchunyu
 * 
 */
@Controller
@Scope("prototype")
public class AddDataValueAction extends BaseAjaxAction<DataValueDTO> {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Override
    public DataValueDTO getDetailData() {
        if (this.detailData == null) {
            this.detailData = new DataValueDTO();
        }
        return this.detailData;
    }

    @Autowired
    private DataDictionaryWebService dataDictionaryWebService;

    private String toId;

    private Long newDataValueId;

    @LogRecord(eventAction="数据字典-添加数据值",eventTarget="detailData")
    @Override
    public String _execute() throws Exception {
        Long newId;
        if (!toId.equals("null")) {
            newId = Long.valueOf(toId);
        } else {
            newId = null;
        }
        newDataValueId = dataDictionaryWebService.addDataValue(this.detailData,
                newId);
        getRequestResult().setRsltCode("0");
        getRequestResult().setMessage("数据值添加成功");
        return SUCCESS;
    }

    public String getToId() {
        return toId;
    }

    public void setToId(String toId) {
        this.toId = toId;
    }

    public Long getNewDataValueId() {
        return newDataValueId;
    }

    public void setNewDataValueId(Long newDataValueId) {
        this.newDataValueId = newDataValueId;
    }
}
